<template>
  <div class="components-container">
    <!-- 查询条件 -->
    <div class="header-form">
     <div class="layui-inline">
        <label class="layui-form-label">区域名称</label>
         <div class="layui-input-inline">
            <el-input v-model="selectData.Icaname" placeholder="请输入冰柜区域名称"></el-input>
         </div>
      </div>
      <el-button type="primary"  @click="btnSearch" :loading="this.$store.state.isloading">搜索</el-button>
      <el-button @click="btnRepeat">重置</el-button>
    </div>
    <!-- 功能列表 -->
    <!-- 功能列表 -->
    <div>
      <ul class="toolList">
        <li v-if="btnShow(item.BTNVALUE)" v-for="(item, index) in $store.state.btnListCommon" @click="operate(item.BTNVALUE)">
          <el-button type="primary" :value="item.BTNSHOWNAME" v-text="item.BTNSHOWNAME"></el-button>
        </li>
      </ul>
    </div>
    <!--数据列表-->
    <dataTable :headList="headList" :dataList="dataList" :pageOrder="pageOrder" @pageChange="pageChange" @selectRow="selectRow"></dataTable>

    <freezerAreaMain ref="sweetModalMain" :orderType="order" @refreshData="getData"></freezerAreaMain>
  </div>
</template>
<style rel="stylesheet/scss" lang="scss" scoped>
  @import "src/styles/common.scss";
  .btnCenter {
    text-align: center;
  }
</style>
<script>
  import freezerAreaMain from './freezerAreaMain';
  import dataTable from "@/components/Table/DataTable";
  import apiBase from '@/api/apiBase.js'
  import {
    manage
  } from "@/mixins/managePage.js";
  const ADD = "新增";
  const MODIFY = "修改";
  const DELETE = "删除";
  const INFO = "详情";
  export default {
    name: "freezerArea",
    mixins: [manage],
    data() {
      return {
        loading: false,
        selectData: {},
        Data: {},
      };
    },
    methods: {
      //功能操作
      operate(order) {
        this.order = order;
        this.dataRepeat();
        switch (this.order) {
          case ADD:            
            this.$refs.sweetModalMain.open(this.order);
            break;
          case MODIFY:
          case INFO:
            this.$refs.sweetModalMain.open(this.order, this.currentRow.ICAID);
            break;
          case DELETE:
            this.$refs.sweetModalMain.open(this.order, this.currentRow.ICAID);
            break;
          default:
        }
      },
      //获取列项
      getColumns() {
        apiBase.DoService({},
          apiBase.getApiAdress().Column.GetIceareaColumns,
          res => {
            this.headList = res.data.content;
          }
        );
      },
      //获取数据
      getData() {
        let Data = JSON.parse(JSON.stringify(this.selectData));
        var data = {
          PageIndex: this.pageOrder.currentPage,
          PageSize: this.pageOrder.pageSize,
          OrderBy: this.pageOrder.orderType,
          OrderByType: this.pageOrder.orderSort,
          Data: Data
        }
        apiBase.DoService(data, apiBase.getApiAdress().Icearea.Query, res => {
          this.dataList = res.data.content.OutData;
          this.pageOrder.totalNum = res.data.content.RecordCount;
        });
      },
      //查询条件重置
      btnRepeat() {
        this.selectData = {};
        this.getData();
      },
      //数据重置
      dataRepeat() {
        this.Data = {};
      }
    },
    mounted() {},
    components: {
      freezerAreaMain,
      dataTable
    },
    created() {
      this.getColumns();
      this.getData();
    }
  }
</script>